﻿using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
public static class F 
{
    public static T Reduce<T>(Func<T, T, T> reducefn, IEnumerator iter)
    {
        T preTValue = default(T);
        if (!iter.MoveNext())
        {
            return default(T);
        }
        preTValue = (T)iter.Current;
        while(iter.MoveNext())
        {
            T curT = (T)iter.Current;
            preTValue = reducefn(preTValue,curT);
        }
        return preTValue;
    }
}
